import axios from "axios"
import {getToken} from "../utils"

const instance = axios.create({
    baseURL: 'http://api.tjxl.vooo.xyz'
});

instance.interceptors.request.use(function (config) { // 每次请求时会从localStorage中获取token
    let token = getToken()
    if (token) {
        config.headers = {
            'Authorization': 'Bearer ' + token
        }
    }
    return config
}, function (error) {
    console.log(error)
    return Promise.reject(error);
})

export default instance;